﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/employee.master" AutoEventWireup="true"
    CodeBehind="schedule_list.aspx.cs" Inherits="RailwayReservationWeb.employee.schedule_list" %>

<asp:Content ID="Content2" ContentPlaceHolderID="PathContent" runat="server">
    <ol class="breadcrumb">
        <li><a href="default.aspx">Home</a></li>
        <li><a href="schedule_list.aspx">Schedule</a></li>
        <li class="active"><a href="schedule_list.aspx">List</a></li>
    </ol>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page-header">
        <h1>
            Schedules List</h1>
    </div>
    <p id="pMessage" runat="server" class="alert alert-danger">
    </p>
    <div class="row">
        <div class="col-md-6">
            <div class="btn-group" style="margin-bottom: 15px">
                <asp:Button ID="btnShow" CssClass="btn btn-default" runat="server" Text="Show Deleted"
                    PostBackUrl="~/employee/schedule_list.aspx" CausesValidation="False" UseSubmitBehavior="False" />
            </div>
        </div>
        <div class="col-md-6">
            <div class="input-group">
                <asp:TextBox ID="txtSearch" CssClass="form-control" runat="server"></asp:TextBox>
                <span class="input-group-btn">
                    <asp:Button ID="btnSearch" CssClass="btn btn-default" runat="server" Text="Search"
                        OnClick="btnSearch_Click" />
                </span>
            </div>
        </div>
    </div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" Width="100%" CssClass="table table-condensed table-bordered table-striped table-hover"
        AutoGenerateColumns="False" DataSourceID="ldsSchedule" Style="font-size: 95%"
        AllowSorting="True" OnRowCommand="GridView1_RowCommand">
        <PagerStyle CssClass="pagerArea" Wrap="True" />
        <PagerTemplate>
            <asp:GridPager ID="GridViewPager1" runat="server" ShowFirstAndLast="True" ShowNextAndPrevious="True"
                PageLinksToShow="10" NextText="&rsaquo;" PreviousText="&lsaquo;" FirstText="&laquo;"
                LastText="&raquo;" />
        </PagerTemplate>
        <Columns>
            <asp:BoundField DataField="ScheduleId" HeaderText="Id" ReadOnly="True" SortExpression="ScheduleId" />
            <asp:BoundField DataField="Train.TrainName" HeaderText="Train Name" SortExpression="Train.TrainName">
            </asp:BoundField>
            <asp:BoundField DataField="Station1.StationName" HeaderText="Origin" SortExpression="Station.StationName">
            </asp:BoundField>
            <asp:BoundField DataField="DepTime" HeaderText="Dep Time" ReadOnly="True" SortExpression="DepTime" />
            <asp:BoundField DataField="Station.StationName" HeaderText="Destination" SortExpression="Station1.StationName">
            </asp:BoundField>
            <asp:BoundField DataField="ArrTime" HeaderText="Arr Time" ReadOnly="True" SortExpression="ArrTime" />
            <asp:BoundField DataField="TravelTime" HeaderText="Travel Time" ReadOnly="True" SortExpression="TravelTime" />
            <asp:TemplateField HeaderText="Days Of Run" SortExpression="RunDays">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# FormatRunDays((String)Eval("RunDays")) %>'
                        CssClass="run-days"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="AltEdit"
                        CommandArgument='<%# Bind("ScheduleId") %>' Text="Edit"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName='<%# ((Int16)Eval("Status")==0)?"AltRestore":"AltDelete" %>'
                        CommandArgument='<%# Bind("ScheduleId") %>' Text='<%# ((Int16)Eval("Status")==0)?"Restore":"Delete" %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            There are currently no items in this table.
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:LinqDataSource ID="ldsSchedule" runat="server" ContextTypeName="RailwayReservationWeb.RailwayReservationDataContext"
        EntityTypeName="" Select="new (ScheduleId, Train, Station, DepTime, Station1, ArrTime, TravelTime, RunDays, Status)"
        TableName="Schedules" Where="Status != @Status">
        <WhereParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="Status" QueryStringField="s" Type="Int16" />
            <asp:QueryStringParameter DefaultValue="" Name="StationName" QueryStringField="q"
                Type="String" />
        </WhereParameters>
    </asp:LinqDataSource>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="SideContent" runat="server">
    <div class="panel panel-primary panel-navi">
        <!-- Default panel contents -->
        <div class="panel-heading">
            Manage Schedule</div>
        <!-- List group -->
        <ul class="list-group">
            <li class="list-group-item"><a href="schedule_list.aspx">View Schedule List</a></li>
            <li class="list-group-item"><a href="schedule_add.aspx">Add New Schedule</a></li>
        </ul>
    </div>
</asp:Content>
